/**
 * 
 * @author antonio081014
 * Date: 2011-05-27
 */
package com.antonio081014.arielclock;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class Main extends TabActivity {
	private TabHost clocksTabs;
	private Resources res; // Resource object to get Drawables
	private TabHost.TabSpec spec; // Resusable TabSpec for each tab
	private Intent intent; // Reusable Intent for each tab

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		res = getResources();
		clocksTabs = getTabHost(); // The activity TabHost

		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this, DateTime.class);
		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = clocksTabs.newTabSpec("datetime").setIndicator(
				res.getString(R.string.str_datetime)).setContent(intent);
		clocksTabs.addTab(spec);

		// Do the same for the other tabs
		intent = new Intent().setClass(this, WorldClock.class);
		spec = clocksTabs.newTabSpec("worldclock").setIndicator(
				res.getString(R.string.str_worldclock),
				res.getDrawable(R.drawable.wall_clock)).setContent(intent);
		clocksTabs.addTab(spec);

		intent = new Intent().setClass(this, Alarms.class);
		spec = clocksTabs.newTabSpec("alarms").setIndicator(
				res.getString(R.string.str_alarm)).setContent(intent);
		clocksTabs.addTab(spec);

		intent = new Intent().setClass(this, Timers.class);
		spec = clocksTabs.newTabSpec("timers").setIndicator(
				res.getString(R.string.str_timer)).setContent(intent);
		clocksTabs.addTab(spec);

		intent = new Intent().setClass(this, StopWatch.class);
		spec = clocksTabs.newTabSpec("stopwatch").setIndicator(
				res.getString(R.string.str_stopwatch)).setContent(intent);
		clocksTabs.addTab(spec);

		clocksTabs.setCurrentTab(0);
	}

}